//
//  AVFormatContext.hpp
//  VideoParse
//
//  Created by xiaerfei on 2020/4/1.
//  Copyright © 2020 erfeixia. All rights reserved.
//

#ifndef AVFormatContext_hpp
#define AVFormatContext_hpp

#include <stdio.h>
#include "AVIOContext.hpp"
#include "AVStream.hpp"
#include "FFDemuxer.hpp"
#include <unordered_map>
#include <string>

#define AV_TIME_BASE            1000000

class AVFormatContext {
    std::unordered_map<std::string, std::string> *metadata;    
public:
    AVIOContext *pb;
    unsigned int nb_streams;
    AVStream **streams;
    FFDemuxer *demuxer;

    int64_t duration;
    
    int open_input(char *url,void *fmt, void *options);
    int find_stream_info(void *options);
    
    int read_header();
    int read_packet(void *pkt);
    int read_close();
    int read_seek(int stream_index, int64_t timestamp, int flags);
    
    
    AVFormatContext();
    
    void add_value_for_key(std::string value, std::string key);
    std::string value_for_key(std::string key);
    
    
    
};



#endif /* AVFormatContext_hpp */
